#!/bin/sh /etc/rc.common

USE_PROCD=1
START=99

CONF="sysuh3c"

start_service() {
	config_load "$CONF"

	local enabled
	config_get_bool enabled "config" "enabled" "0"
	[ "$enabled" -eq "1" ] || return 1

	local username password method ifname
	config_get username "config" "username"
	config_get password "config" "password"
	config_get method "config" "method"
	config_get ifname "config" "ifname"

	procd_open_instance
	procd_set_param command "/usr/sbin/sysuh3c"
	procd_append_param command -u "$username"
	[ -z "$password" ] || procd_append_param command -p "$password"
	[ -z "$method" ] || procd_append_param command -m "$method"
	procd_append_param command -i "$ifname"

	procd_set_param respawn 3600 10 5
	procd_set_param stdout 1
	procd_set_param stderr 1

	procd_close_instance
}

service_triggers() {
	procd_add_reload_trigger "$CONF"
}
